home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / osr5 / sco / scripts / kshfuncs / dirs < prev    next >
Encoding:
Text File  |  1997-08-26  |  945 b   |  34 lines

  1. # @(#) dirs.ksh 1.0 1991
  2. # 1991 john h. dubois iii (john@armory.com)
  3. # Lists directory history maintained by 'ucd'.
  4. # Usage:
  5. # dirs [num]
  6. # num is the number of history entries to list.  If num is not given, the
  7. # number of entries listed is based on the number that will fit on the screen.
  8. # If this cannot be determined, 23 history entries are listed.
  9. # The format of the output is
  10. # histslot: directory-name
  11. # where histslot is the history index (the number that would be given to ucd
  12. # to cd to that slot; always preceded by a '-') of the named directory.
  13. function dirs {
  14.     typeset -i i=1 ind=_dind num=23
  15.     typeset -L4 printind
  16.     typeset dir
  17.  
  18.     if [ "$1" -gt 0 ]; then
  19.     num=$1
  20.     elif [ -z "$LINES" ]; then
  21.     num=$LINES-2
  22.     fi
  23.     while [ i -le num ]; do
  24.     printind=-$i:
  25.     dir=${_olddirs[ind]}
  26.     if [ -z "$dir" ]; then break; fi
  27.     print -- "$printind $dir"
  28.     let ind-=1
  29.     if [ ind -lt 0 ]; then ind=_numdirs-1; fi
  30.     let i+=1
  31.     done
  32. }
  33.  
  34.